package cn.training.service;

import java.util.List;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.training.bean.UserBean;

@Service
public class HelloWorldService {

	@Autowired
	QueryDAO queryDao;

	@Autowired
	UpdateDAO updateDao;

	
	public UserBean searchUser(UserBean result) {
		 result = queryDao.executeForObject("User.selectUser", result,UserBean.class);
		//frm.setUserId("test");
		
		return result;
		
	}
	
public List<UserBean> checkUser(UserBean frm) {

		List<UserBean> result = queryDao.executeForObjectList("User.cxUser", frm);

		return result;
	
	
	}
	
	
	public int deleteUser(UserBean frm) {
		int result = updateDao.execute("User.deleteUser", frm);
		//frm.setUserId("test");
		
		return result;
	}
	

		
		//return result;
	//}
	
public int insert(UserBean frm)
	{
	int result=0;
	try{
		
		return updateDao.execute("User.userinsert", frm);
	}
		catch(Exception e)
	{
			result=999;
	}
	return result;
	}

public int update(UserBean frm){
	
	return updateDao.execute("User.userupdate", frm);
}
}
